<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>
	<div id="demo">
		<button v-on:click.once="counter += 1">Add 1</button>
		<p>The button above has been clicked {{ counter }} times.</p>
		
		<button v-on:click="greet('Hello Vue', $event)">Greet</button>
	</div>
<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript">
	const vm = new Vue({
		el:'#demo',
		data:{
			counter: 0,
			name: 'Vue.js'
		},
		methods:{
			// event 为 js默认提供的事件的对象, event是原生 DOM 事件
			greet:function(message, event) {
				alert('Hello ' + this.name + '!' + message);
				if(event) {
					alert(message + event.target.innerHTML) // 获取标签文本
				}
			}
		}
	});
</script>
</body>
</html>
